function onUpdate(rid){
		$('#modalTable').modal('show');
		$('#modalTitle').html('编辑窗体');
		//查询参数
			$.ajax({type : "GET",
						url :  _ctx + "/sys/dict/update/"+rid,							
						success : function(result) {								
							$("input[uname='update']").each(function(index, item){									
								$(item).val(result[item.name]);
							});
							$('#modalTable').attr('action','update');							
						}});
	}

	function onDelete(rid) {
		bootbox.dialog({
			message : "确认删除该记录，该操作不可逆。",
			title : "<i class='icon-warning-sign'></i> 警告",
			buttons : {
				danger : {
					label : "确认删除",
					className : "btn-danger",
					callback : function() {
						$.ajax({
							type : "POST",
							url : _ctx + "/sys/dict/delete/" + rid,
							success : function(data) {
								//save ok
								if (data == 1) {
									$('#frmSearch').submit();
								} else {
									bootbox.dialog({
										message: "<i class='icon-warning-sign'></i>&nbsp;&nbsp;" + data,
										buttons: 			
										{
											"success" :
											 {
												"label" : "<i class='icon-ok'></i> 关闭",
												"className" : "btn-success",
												"callback": function() {
													//Example.show("great success");
												}
											}
										}
									});	
								}
							}
						});
					}
				}
			}
		});
	}

	$(document).ready(function() {
		/* var oTable1 = $('#sample-table-2').dataTable({
			"aoColumns" : [ {
				"bSortable" : false
			}, null, null, {
				"bSortable" : false
			} ],
		});   */
		
		/**
		 * 重置缓存
		 */
		$('#btnRstCache').click(function(){
			$.get(_ctx + '/sys/dict/rstCache', function(result){
				if(result == '1') {
					parent.commonAPI.warn('错误','重置缓存失败!');
				} else {
					parent.commonAPI.info('提示','重置缓存成功。');
				}				
			});
		});
		
		/* 批量删除 */
		$("#btnDelete").click(function() {
			// 判断是否至少选择一项    
			var selectedList = $.find("input[class='ace']:checked");
			var checkedNum = selectedList.length;
			if (checkedNum == 0) {
				bootbox.alert("请选择至少一项！", function(result) {});				
				return;
			}

			// 批量选择
			bootbox.dialog({
				message: "<i class='icon-warning-sign'></i>&nbsp;&nbsp;<span class='bigger-110'>确认批量删除"+checkedNum+"条记录吗?</span>",
				buttons: 			
				{
					"success" :
					 {
						"label" : "<i class='icon-ok'></i> 关闭",
						"className" : "btn-success",
						"callback": function() {
							//Example.show("great success");
						}
					},
					"danger" :
					{
						"label" : "删除",
						"className" : "btn-danger",
						"callback": function() {
							var checkedList = new Array();
							$(selectedList).each(function() {
								if($(this).val()!="on"){										
									checkedList.push($(this).val());
								}
							});
							//提交到数据库
							$.ajax({
								type : "GET",
								url : _ctx + "/sys/dict/delete/"+checkedList,
								data : {
									'delitems' : checkedList.toString()
								},
								success : function(result) {
									if(result==1){
										$("input[class='ace']:checked").attr("checked", false);
										$('#frmSearch').submit();
									} else {
										bootbox.alert("删除失败.", function(result) {});											
									}
								}
							});
						}
					}
				}
			});
		});

		$('table th input:checkbox').on(
				'click',
				function() {
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox').each(
							function() {
								this.checked = that.checked;
								$(this).closest('tr').toggleClass('selected');
							});
				});

		$('#sort').ace_spinner({
			min : 0,
			max : 1000,
			step : 1,
			touch_spinner : true,
			icon_up : 'icon-caret-up',
			icon_down : 'icon-caret-down'
		});
		
		$('#btnNew').click(function(){
			$('#modalTable').modal('show');
			$('#modalTitle').html('新增窗体');
			$("input[uname='update']").each(function(index, item){									
				$(item).val("");
			});
		});
		
		$('#btnSubmit').click(function() {
			var action = $('#modalTable').attr('action');
			var url = '';
			if(action=='new') {
				url = _ctx + "/sys/dict/create";
			} else {
				url = _ctx + "	/sys/dict/update";
			}
			
			$.ajax({
				type : "POST",
				url : url,
				data : $("#frmSubmit").serialize(), // serializes the form's elements.
				success : function(data) {
					//save ok
					$('#modalTable').hide();
					if (data == 1) {
						bootbox.confirm("保存成功!", function(result) {
							//刷新当前页面
							$('#frmSearch').submit();
							$('#modalTable').attr('action', 'new');
							$('#modalTable').modal('hide');
						});
					} else {
						bootbox.confirm("保存失败!", function(result) {
							$('#modalTable').hide();
						});
					}
				}
			});
		});
	});